using System;
using System.Collections;
using System.Diagnostics;

using Microsoft.MediaCenter.UI;


namespace MyVideoViewerMCPlugin
{
    /// <summary>
    /// This object contains the standard set of information displayed in the 
    /// gallery page UI.
    /// </summary>
    public abstract class GalleryPage : FilteredContentPage
    {
            /// <summary>
        /// The desired size for a galley item.  This will be interpreted by the 
        /// UI to control what size to allow for the thumbnails as well as how 
        /// many rows to display.
        /// </summary>
        public GalleryItemSize ItemSize
        {
            get { return itemSize; }
            set 
            {
                if (itemSize != value)
                {
                    itemSize = value;
                    FirePropertyChanged("ItemSize");
                }
            }
        }
        private GalleryItemSize itemSize;

        private bool showChangeItemSize;
        public bool ShowChangeItemSize
        {
            get { return showChangeItemSize; }
            set
            {
                showChangeItemSize = value;
                FirePropertyChanged("ShowChangeItemSize");
            }
        }

        public void ChangeItemSize(string size)
        {
            GalleryItemSize temp = (GalleryItemSize)Enum.Parse(typeof(GalleryItemSize), size, true);
            if (itemSize != temp)
            {
                ItemSize = temp;
                OnActiveFilterChanged(Filters, EventArgs.Empty);
            }
        }

        /// <summary>
        /// Helper method to load an image from our data directory.
        /// </summary>
        protected static Image LoadImage(string imageName)
        {
            try
            {
                return new Image(imageName);
            }
            catch (Exception)
            {
                //return Resources.NoImage;
                //return new Image("resx://MyVideoViewerMCPlugin/MyVideoViewerMCPlugin.Resources/NoImage");
                Debug.WriteLine("Error loading image: " + imageName);
            }

            return null;
        }


    }

    /// <summary>
    /// The possible size configurations supported by the gallery UI.
    /// </summary>
    public enum GalleryItemSize
    {
        Small,
        Medium,
        Large,
        Poster
    }
}
